FROM alpine:3.9

ENV PYTHONUNBUFFERED=1
ENV API_SERVER_HOME=/opt/www

WORKDIR "$API_SERVER_HOME"

COPY "./requirements.txt" "./requirements.txt"

EXPOSE 5000

ARG INCLUDE_POSTGRESQL=false
ARG INCLUDE_UWSGI=false


RUN  echo 'https://mirrors.aliyun.com/alpine/v3.9/main/' >/etc/apk/repositories && echo 'https://mirrors.aliyun.com/alpine/v3.9/community/' >>/etc/apk/repositories
RUN  echo "**** install Python ****" && \
    apk add --no-cache python3 && \
    if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \
    echo "**** install pip ****" && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install  -U -i https://mirrors.aliyun.com/pypi/simple/ --no-cache --upgrade pip setuptools wheel && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi

RUN  apk add --no-cache  --virtual=.build_dependencies python3-dev musl-dev libevent-dev  py3-cffi linux-headers  openssl-dev libxslt libxslt-dev g++ && \
    apk add --no-cache  tzdata postgresql-dev gcc libffi-dev yasm ffmpeg make && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&  \
    echo "Asia/Shanghai" >/etc/timezone  &&  \
    pip3 install  -i https://mirrors.aliyun.com/pypi/simple/  -r ../requirements_all.txt
